﻿using System;
using System.Web.SessionState;

namespace FBGraph.Web
{
    /// <summary>An implementation of <see cref="IHttpSessionStateWrapper" /> that wraps <see cref="HttpSessionState" />.</summary>
    public class ClassicHttpSessionStateWrapper : IHttpSessionStateWrapper
    {
        private HttpSessionState session;

        internal ClassicHttpSessionStateWrapper(HttpSessionState session)
        {
            this.session = session;
        }

        /// <summary>Gets the unique identifier for the session.</summary>
        public String SessionID { get { return this.session.SessionID; } }

        /// <summary>Gets or sets a session value by numeric index.</summary>
        /// <param name="index">The numeric index of the session value.</param>
        /// <returns>The session-state value stored at the specific index, or a null reference if the item does not exist.</returns>
        public Object this[Int32 index]
        {
            get { return this.session[index]; }
            set { this.session[index] = value; }
        }

        /// <summary>Gets or sets a session value by name.</summary>
        /// <param name="key">The key name of the session value.</param>
        /// <returns>The session-state value with the specified name, or a null reference if the item does not exist.</returns>
        public Object this[String key]
        {
            get { return this.session[key]; }
            set { this.session[key] = value; }
        }
    }
}